﻿


using System;

namespace WssUtils
{

    public static class TimeStamp
    {
        public const long MillisecondPerDay = 86400000;
        public const long MillisecondPerHour = 3600000;
        public const long MillisecondPerMinute = 60000;
        public const long MillisecondPerSecond = 1000;
        public static long Days
        {
            get
            {
                System.TimeSpan ts = System.DateTime.Now - new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
                return System.Convert.ToInt64(ts.Days);
            }
        }

        public static long Now
        {
            get
            {
                System.TimeSpan ts = System.DateTime.Now - new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
                return System.Convert.ToInt64(ts.TotalMilliseconds);
            }
        }


        public static TimeSpan GetTimeSpan(long timeStampMS)
        {
            long lTime = timeStampMS * 10000;
            TimeSpan toNow = new TimeSpan(lTime);
            return toNow;
        }

        public static DateTime GetDateTime(long timeStampMS)
        {
            DateTime dtStart = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
            long lTime = timeStampMS * 10000;
            TimeSpan toNow = new TimeSpan(lTime);
            return dtStart.Add(toNow);
        }

        public static long GetTimeStampOffsetNow(long timeStamp)
        {
            return Now - timeStamp;
        }

    }

}